{extend name="public/base" /}

{block name="title"}<title>{$Think.lang.list}</title>{/block}

{block name="pjax_container"}
<div class="hry-content-wrapper">
    <section class="content-header">
        <ol class="breadcrumb">
            <li>项目管理</li>
            <li class="active">项目列表</li>
        </ol>
    </section>
<section class="content">
    <div class="row">
        <div class="col-md-12">
            <div class="hry-form-wrapper">
                <div class="box-header with-border">
                    <h3 class="box-title"></h3>
                    <div class="pull-left">
                        {:authAction(CONTROLLER_NAME.'/create', 'create')} 
                    </div>
                    {include file="public/project_search" /}
                </div>
                <div class="box-body table-responsive">
                    <table class="table table-bordered table-hover table-sort">
                        <tr>
                            <th>{$Think.lang.id}{:table_sort('id')}</th>
                            <th>{$Think.lang.thumb}</th>
                            <th>{$Think.lang.title}</th>
                            <th>{$Think.lang.target_code}{:table_sort('target_code')}</th>
							<th>支持金额</th>
							<th>{$Think.lang.project_type}</th>
                            <th>{$Think.lang.initiator}</th>
                            <th>{$Think.lang.status}</th>
                            <th>{$Think.lang.create_time}</th>
                            <th>{$Think.lang.top}</th>
                            <th width="178">{$Think.lang.action}</th>
                        </tr>
                        {volist name="dataList" id="vo"}
                        <tr>
                            <td>{$vo.id}</td>
							 <td><img src="{$vo.thumb}" width="50" height="30"></td>
                            <td>
								<span class="editable" data-pk="{$vo.id}" data-name="project_name" data-url="{:url(CONTROLLER_NAME.'/edit', 'id='.$vo['id'])}" >{$vo.project_name}</span>
                            </td>
                            <td>{$vo.target_code}</td>
                            <td>{$vo.have_money}</td>
                            <td>{if condition="$vo.project_type eq 1"}{$Think.lang.project_type1}{else}{$Think.lang.project_type2}{/if}</td>
                            <td>{if condition="$vo.company_name"}{$vo.company_name}{else}{$Think.lang.noinitiator}{/if}</td>
                            <td>{$PstatusList[$vo.status]}</td>
                            <td>{$vo.create_time}</td>
                            <td>
                                <a href="javascript:void(0);" data-id="{$vo.id}" data-field="top" 
                                data-value="{$vo.top}" data-url="{:url('edit', 'id='.$vo['id'])}" 
                                class='editimg fa {if condition=" $vo.top == 1 "}fa-check-circle text-green{else /}fa-times-circle text-red{/if}'></a>
                            </td>
                            <td>
                                {if condition="$vo.has_authorize eq '1'" }
                                <a class="btn-text btn-primary" href="javascript:void(0);">
                                    <span class="color-no">详情</span>
                                </a>
                                {/if}
                                {if condition="$vo.has_authorize eq '2'" }
                                <a class="btn-text btn-primary project_detail" href="/hryweb.php/Project/authDetail?id={$vo.id}">详情</a>
                                {/if}

								<a class="btn-text btn-primary" href="/Project/detail/id/{$vo.id}">预览</a>

                                {if condition="$vo.has_authorize eq '1'" }
                                <a class="btn-text btn-primary"  href="javascript:void(0);">
                                    <span class="authorize_project" data-pid="{$vo.id}">授权</span>
                                </a>
                                {/if}

                                {if condition="$vo.has_authorize eq '2'" }
                                <a class="btn-text btn-primary"  >
                                    <span class="color-no">已授权</span>
                                </a>
                                {/if}

                                {if condition="$vo.status eq 0"}
                                {:authAction(CONTROLLER_NAME.'/edit', 'edit', ['id' => $vo.id])}
                                {/if}

                                <!--{:authAction(CONTROLLER_NAME.'/delete', 'delete', $vo.id)}-->
                                <!--{include file="public/list_action" /}-->
                            </td>
                        </tr>
                        {/volist}
                    </table>
                </div>
                <div class="box-footer clearfix">
                    {$dataList->render()}
                </div>
            </div>
        </div>


    </div>
</section>
</div>

<script type="text/javascript">
$(function(){
    /*ajax页面加载icheck，有该控件的页面才需要*/
    $('input[type="checkbox"].minimal, input[type="radio"].minimal').iCheck({
        checkboxClass: 'icheckbox_minimal-blue',
        radioClass: 'iradio_minimal-blue'
    });
    
    /*ajax页面加载icheck，有该控件的页面才需要*/
    $(".select2").select2({language:"zh-CN"});
    
    /*全选-反选*/
    $('.checkbox-toggle').on('ifChecked', function(event){
        var _this = $(this);
        var _table = _this.closest('.table');
        _table.find("tr td input[type='checkbox']").iCheck("check");
    });
    $('.checkbox-toggle').on('ifUnchecked', function(event){
        var _this = $(this);
        var _table = _this.closest('.table');
        _table.find("tr td input[type='checkbox']").iCheck("uncheck");
    });
    
    $('.editable').editable({
        emptytext: "empty",
        params: function(params) {      //参数
            var data = {};
            data['id'] = params.pk;
            data[params.name] = params.value;
            return data;
        },
        success: function(response, newValue) {
            var res = $.parseJSON( response );
            if(res.status == 1){
            }else{
                return res.info;
            }
        }
    });

    
    {if condition=" $rest_login == 1 "}
    restlogin('{$rest_login_info}');   //登录超时
    {/if}
})
$(".ss").on('click','', function(){
    data=$(this).data("id");
    $.ajax({
        url:"batchht",
        data:{
            id:data
        },
        type:"POST",
        dataType:"json",
        success:function(JSON){
            console.log(JSON);
            $.amaran({'message':JSON.info})
//                    debugger;
        },
        error:function(xhr,status,errorThrown){
//                    debugger;
        },
        complete:function(xhr,status){
//                    alert('The request is complated');
        },
        beforesend:function(){
        },
        cache:false,//true
        async:true
    });//ajax end here
});

    $(".authorize_project").on('click','',function(){ //项目授权
         $pid = $(this).data("pid"); //项目id
         $res=confirm('是否确定对该项目发起信息授权，该操作不可撤销');
        if($res){
            $.ajax({
                url: '/hryweb.php/project/authorizeProject',
                data: {'pid':$pid},
                type: "POST",
                dataType: "json",
                success: function (result) {
                    if (result.status == 1) {
                        $.amaran({'message': result.info});
                        window.location.href = result.url;
                    } else {
                        $.amaran({'message': result.info});
                    }
                },
                async:true
            });

        }
    });
</script>

<style type="text/css">
    .color-no{
        color: grey !important;
    }
</style>


{/block}